package service

import (
	"context"
	"github.com/plutov/paypal/v4"
	"video-api/internal/model/input"
	"video-api/internal/model/out"
)

type (
	// IOceanPaymentPayService 钱海支付
	IOceanPaymentPayService interface {
		OrderPay(context.Context, *input.OrderPay) (orders *out.OrderEntity, err error)
		GenerateSignature(context.Context, any) (string, error)
		RequestApiToPay(context.Context, any) error
		NoticePayment(context.Context, any) error
	}
	// IOtherPaymentPayService TODO 其他支付
	IOtherPaymentPayService interface {
		OrderPay(context.Context, any) error
		GenerateSignature(context.Context, any) (string, error)
		NoticePayment(context.Context, any) error
	}
	IPaymentPayService interface {
		CreateOrder(context.Context, *out.OrderEntity) (*paypal.Order, error)
		OrderPay(context.Context, *input.OrderPay) (*out.OrderEntity, error)
	}
)

var oceanPayInstance IOceanPaymentPayService

func OceanPayService() IOceanPaymentPayService {
	if oceanPayInstance == nil {
		panic("oceanPayInstance is not initialized")
	}
	return oceanPayInstance
}

func RegisterOceanPayService(p IOceanPaymentPayService) {
	oceanPayInstance = p
}

// paypal支付
var paymentPayInstance IPaymentPayService

func PaymentPayService() IPaymentPayService {
	if paymentPayInstance == nil {
		panic("oceanPayInstance is not initialized")
	}
	return paymentPayInstance
}

func RegisterPaymentPayService(p IPaymentPayService) {
	paymentPayInstance = p
}

// TODO 其他支付
//var otherPayInstance IOtherPaymentPayService
//
//func OtherPayService() IOtherPaymentPayService {
//	if otherPayInstance == nil {
//		panic("otherPayInstance is not initialized")
//	}
//	return otherPayInstance
//}
//
//func RegisterOtherPayService(p IOtherPaymentPayService) {
//	otherPayInstance = p
//}
